<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="WEB-INF/facelets/template.xhtml">

        <ui:param name="title" value="My Account"/>

        <ui:define name="content">
            <h1>This is account.xhtml</h1>

            <form id="accountForm" action="changesettings" method="POST">
                <input type="hidden" name="action" value="changesettings"/>
                <table>
                    <tr>
                        <td>
                            <h:outputLabel for="name" value="Name:"/>
                            <h:inputText id="name" 
                                         value="#{accountBacking.user.getName()}"
                                         required="true"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel for="email" value="Email:"/>
                            <h:inputText styleClass="big" 
                                         id="email" 
                                         value="#{accountBacking.user.getEmailAddress()}"
                                         required="true"
                                         validator="#{accountBacking.checkEmail}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel for="street" value="Street:"/>
                            <h:inputText styleClass="big" 
                                         id="street" 
                                         value="#{accountBacking.user.getAddress().getStreetWithNumber()}"
                                         required="true"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel for="zipcode" value="ZIP Code:"/>
                            <h:inputText id="zipcode" 
                                         styleClass="zip" 
                                         value="#{accountBacking.user.getAddress().getZipCode()}"
                                         required="true"/>

                            <h:outputLabel styleClass="city" for="city" value="City"/>
                            <h:inputText id="city"
                                         value="#{accountBacking.user.address.area}"
                                         required="true"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel for="oldpasswd" value="Old Password:"/>
                            <h:inputSecret id="oldpasswd" 
                                           binding="#{oldPass}" 
                                           value="#{accountBacking.oldPassWord}"/>

                        </td>
                        <td><p>Only required if you want to change password.</p></td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel for="passwd" value="New Password:"/>
                            <h:inputSecret id="passwd" 
                                           binding="#{newPass}"
                                           value="#{accountBacking.user.password}"/>

                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel for="passwdrepeat" value="Repeat New Password:"/>
                            <h:inputSecret id="passwdrepeat"
                                           validator="#{accountBacking.verifyPassword}">

                                <f:attribute name="pass" value="#{newPass.value}" />
                                <f:attribute name="oldpass" value="#{oldPass.value}" />
                            </h:inputSecret>
                        </td>
                        <td><h:message for="passwdrepeat" /></td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel for="newsletter" value="Newsletter"/>
                            <h:selectBooleanCheckbox id="newsletter" 
                                                     styleClass="checkbox" 
                                                     value="#{accountBacking.user.newsLetter}" />
                        </td>
                    </tr>
                </table>
                <h:commandButton value="Update Profile" action="#{accountController.updateUser()}" />
            </form>
        </ui:define>
    </ui:composition>
</html>

